#include<string.h>
#include"process.h"



const char *str = "|/-\\";

void process3(int rate)
{
    static char bar[SIZE]= {0};
    
    int num = strlen(str);
    static int cnt = 0;
    if(rate>=0&&rate<=100)
    {
        cnt++;
        cnt%=num;
        printf("[%-100s][%d%%][%c]\r",bar,rate,str[cnt]);
        fflush(stdout);
        bar[rate] = STYLE_BODY;
        if(rate<MAX_RATE-1)
        {
            bar[rate+1] = STYLE_HEADER;
        }
        
    }
    if(rate == MAX_RATE)
        memset(bar,'\0',sizeof(bar));
}



void process2(int rate)
{
    static char bar[SIZE]= {0};
    
    int num = strlen(str);
    if(rate>=0&&rate<=100)
    {
        printf("[%-100s][%d%%][%c]\r",bar,rate,str[rate%num]);
        fflush(stdout);
        bar[rate] = STYLE;
    }
    if(rate == MAX_RATE)
        memset(bar,'\0',sizeof(bar));
}







void process1()
{
    int count = 0;
    char bar[SIZE];
    memset(bar,'\0',sizeof(bar));
    int num = strlen(str);    
    while(count<=MAX_RATE)
    {
        printf("[%-100s][%d%%][%c]\r",bar,count,str[count%num]);
        fflush(stdout);
        usleep(STIME);
        bar[count++] = STYLE;
    }
    printf("\n");
}
